<template>
  <div>
    <div class="container">
      <Nav></Nav>
      <div class="main">
        <div class="mainNav">
          <el-menu
            style="border:none"
            background-color="#fff"
            text-color="#333"
            active-text-color="#F56C6C" 
            @select='getData'
          >
            <el-submenu index="group1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>我的订单</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="1">待付款</el-menu-item>
                <el-menu-item index="2">已付款</el-menu-item>
                <el-menu-item index="3">已完成</el-menu-item>
                <el-menu-item index="4">待评价</el-menu-item>
                <el-menu-item index="5">已评价</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <el-submenu index="group2">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>我的接单</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="6">未完成</el-menu-item>
                <el-menu-item index="7">已完成</el-menu-item>
                <el-menu-item index="8">收入</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
            <!-- <el-submenu index="group3">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>设置</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="2">修改个人信息</el-menu-item>
                <el-menu-item index="3">更换头像</el-menu-item>
              </el-menu-item-group>
            </el-submenu> -->
          </el-menu>
        </div>
        <div class="menu">
          <!-- <div class="list_title">列表</div> -->
          <div class="list_sort">
            <div >
              <el-table size="mini" border style="width: 100%" height="300px" :data="data" >
                <el-table-column prop="id" label="订单编号" width="80" align="center"></el-table-column>
                <el-table-column prop="name" label="师傅" width="120" align="center"></el-table-column>
                <el-table-column prop="bookingTime" label="预约时间" width="180" align="center"></el-table-column>
                <el-table-column prop="address" label="预约地址" width="180" align="center"></el-table-column>
                <el-table-column prop="dishName" label="菜单" width="180" align="center"></el-table-column>
                <el-table-column prop="money" label="价格" width="120" align="center"></el-table-column>
                <el-table-column prop="status" label="状态" width="120" align="center"></el-table-column>
                <el-table-column prop="remark" label="备注" width="100" align="center"></el-table-column>
                <el-table-column v-if="activeIndex == 5" prop="content" label="评价" width="100" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                  <template slot-scope="scope" v-if="activeIndex == 1">
                    <el-button type="primary" icon="el-icon-edit" circle @click="handleEdit(scope.row)">去付款</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </div>
            
            <!--  layout:分页条布局  prev:上页按钮  pager:页码  next：下一页按钮  page-size: 每页显示数量  total：总条目数-->
            <div class="pagination">
              <el-pagination background :current-page="currentPage" :page-size="pageSize" :total="total"
                layout="total,prev,pager,next" @current-change="handleCurrentChange"></el-pagination>
            </div>
          </div>
          <!-- <div class="list_s2_content" v-if="menu.length != 0">
            <div class="list_s2_item"  v-for="(menuItem,i) in menu" :key="i" >
              <div @click="goMenudetail(menuItem)" >
                <Ordertable :orderData="tableData"></Ordertable>
                <div class="imgw">
                  <div class="list_s2_item_img">
                    <img :src="menuItem.main_image" alt="">
                  </div>
                </div>
                <div class="list_s2_item_info">
                  <strong>{{menuItem.name}}</strong>
                  <div>{{menuItem.goods}}</div>
                </div> 
                
              </div>
            </div>
          </div> -->
        </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Nav from '@/components/nav';
import { selectOrderByUserId } from "../../api/index";
import { mixin } from "../../mixins";
import { mapGetters } from "vuex"; // mapGetters从整个工程其他地方获取数据
import Ordertable from '@/components/ordertable'
export default {
  components:{
    Nav,
    Ordertable
  },
  mixins:[mixin],
  data() {
    return {
      menu:[],
      activeIndex:1,
      tableData: [],//数据库表数据
      //分页设置
      currentPage: 0,//当前页
      pageSize: 0,//分页的每页显示多少个
      total: 0,//总条数
    };
  },
  computed: {
    data() {
      return this.tableData;//查找数据库数据
    },
    ...mapGetters([ "id","username"]),
  },
  // mounted(){
  //  this.getMenu('1');
  // },
  //生命周期函数
  created() {
    this.getData();
  },
  methods: {
    // goMenudetail(menu){
    //   let _this = this;
    //   _this.notify(menu,"success")
    //   this.$router.push({path:'/menuDetail',query:{id:menu.id}});
    // },
    //获取当前页
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getData(); 
    },
   //查询所有用户  以及分页
    getData(index) {
      this.activeIndex = index;
      this.tableData = [],
      selectOrderByUserId(this.currentPage,this.id,index).then((res) => {
          this.tableData = res.records;
          this.pageSize = res.size;
          this.total = res.total;
        })
    },
  },
};
</script>

<style scoped>
ol,
ul {
  list-style: none;
}
a {
  text-decoration: none;
}
.container {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #f1f1f1;
  overflow: auto;
}

.main {
  margin: 0 auto;
  width: 1200px;
  display: flex;
}
.mainNav {
  width: 220px;
  min-width: 220px;
  box-sizing: border-box;
  background-color: #fff;
  border-radius: 12px;
  text-align: left;
  margin-top: 20px;
  height: 500px;
  padding: 10px;
}
.body {
  padding: 0 400px;
  position: absolute;
  top: 100px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  /* justify-content: space-between; */
}
.list_title {
  height: 40px;
  font-size: 32px;
  color: #222;
  font-weight: 600;
  line-height: 40px;
  padding: 0px 0px 12px;
}
.menu {
  width: 1100px;
  /* box-sizing: border-box; */
  padding-top: 20px;
  padding-right: 10px;
  padding-left: 30px;
  text-align: left;
}
.pagination {
  margin: 20px 0;
  text-align: right;
}
.list_sort {
  display: flex;
  color: #666;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.list_sort span {
  margin-right: 10px;
}
.list_s2_item {
  width: 224px;
  height: 360px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  margin: 0px 20px 20px 0px;
  display: inline-block;
  vertical-align: top;
  box-shadow: 0px 4px 12px rgb(0 0 0 / 0%);
  transition: all ease 0.3s;
  cursor: pointer;
}
.list_s2_item .imgw {
  position: relative;
  height: 280px;
  overflow: hidden;
}
.list_s2_item_img {
  height: 280px;
  display: block;
}
.list_s2_item_info {
  display: block;
  height: 80px;
}
.list_s2_item_info strong {
  margin: 10px;
  color: #222;
}
.list_s2_item_info div {
  margin: 10px;
  color: #909399;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.right_item_s1 {
  margin-top: 20px;
  width: 200px;
  margin-bottom: 40px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.title_s2 {
  height: 32px;
  padding: 20px 0px 20px 20px;
  font-size: 24px;
  color: #222;
  font-weight: 600;
  line-height: 32px;
  position: relative;
}
.right_item_s1 ul {
  font-size: 0px;
  padding: 0px 20px 14px;
}
.right_item_s1 ul li {
  margin: 0px 10px 10px 0px;
  display: inline-block;
  vertical-align: top;
}
.right_item_s1 ul li a {
  border-radius: 4px;
  display: inline-block;
  padding: 0px 10px;
  height: 36px;
  line-height: 36px;
  font-weight: 400;
  color: #666;
  transition: all ease 0.3s;
  font-size: 16px;
  background: #f5f5f5;
}
.page{
    margin-bottom: 20px;
}
</style>